package com.anolesoft.qxgl.service.giveRole.mapper;

import com.anolesoft.qxgl.dto.giveRole.GiveRoleDto;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GiveRoleServiceMapper {
    /**
     * 查询当前人员拥有角色 加厂代号
     * @param id
     * @return
     */
    @Select(" select a.role_uid " +
            " from PERM_USER_AUTHORIZATION a " +
            " left join view_sys_perm_emp b on a.user_uid = b.objuid " +
            " left join PERM_ROLE c on a.role_uid = c.objuid " +
            " where b.objuid = #{id, jdbcType=VARCHAR}")
    List<String> selectRole(String id);

    /**
     * 删除当前人员原角色
     * @param id
     * @return
     */
    @Delete(" delete from PERM_USER_AUTHORIZATION where user_uid = #{id, jdbcType=VARCHAR} ")
    int deleteOldRole(String id);

    /**
     * 新增当前人员角色
     * @param giveRoleDto
     * @return
     */
    @Insert(" insert into PERM_USER_AUTHORIZATION (user_uid, role_uid, create_user) values " +
            " (#{userUid, jdbcType=VARCHAR}, #{oneRoleUid, jdbcType=VARCHAR}," +
            "  #{createUser, jdbcType=VARCHAR})")
    int addNewRole(GiveRoleDto giveRoleDto);

}
